//
//  FYRootViewController.m
//  ThePainter
//
//  Created by Sean on 15/8/9.
//  Copyright (c) 2015年 FeiYu. All rights reserved.
//

#import "FYRootViewController.h"

@interface FYRootViewController ()

- (void)btnAddAction;

@end

@implementation FYRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    FYFirstListPage *firstList = [[FYFirstListPage alloc] initWithStyle:UITableViewStylePlain];
    FYFirstNavPage *firstNav = [[FYFirstNavPage alloc] initWithRootViewController: firstList];
    [self addChildViewController:firstNav];
    
    FYDiscoveryListPage *discList = [[FYDiscoveryListPage alloc] initWithStyle:UITableViewStylePlain];
    FYDiscoveryNavPage *discNav = [[FYDiscoveryNavPage alloc] initWithRootViewController:discList];
    [self addChildViewController:discNav];
    
    //中间的tab留出来，放置加号按钮
    [self addChildViewController:[[UIViewController alloc] init]];
    
    FYMessegeListPage *msgList = [[FYMessegeListPage alloc] initWithStyle:UITableViewStylePlain];
    FYMessegeNavPage *msgNav = [[FYMessegeNavPage alloc] initWithRootViewController:msgList];
    [self addChildViewController:msgNav];
    
    FYMinePage *mine = [[FYMinePage alloc] init];
    [self addChildViewController:mine];
    
}

- (void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
    
    UITabBar *tabBar = self.tabBar;
    tabBar.tintColor = [UIColor redColor];
    NSArray *items = [tabBar items];
    
    UITabBarItem *item1 = items[0];
    item1.title = @"首页";
    item1.image = [UIImage imageNamed:@"icon_tab_home"];
    
    UITabBarItem *item2 = items[1];
    item2.title = @"发现";
    item2.image = [UIImage imageNamed:@"icon_tab_square"];
    
    UITabBarItem *itemMiddle = items[2];
    itemMiddle.enabled = NO;
    //在中间添加加号按钮
    CGFloat tbW = CGRectGetWidth(tabBar.frame);
    CGFloat tbH = CGRectGetHeight(tabBar.frame);
    UIButton *add = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, tbH / 3 * 2, tbH / 3 * 2)];
    add.center = CGPointMake(tbW / 2, tbH / 2);
    [add setImage:[UIImage imageNamed:@"icon_publish"] forState:UIControlStateNormal];
    [add addTarget:self action:@selector(btnAddAction) forControlEvents:UIControlEventTouchUpInside];
    [tabBar addSubview:add];
    
    UITabBarItem *item3 = items[3];
    item3.title = @"消息";
    item3.image = [UIImage imageNamed:@"icon_tab_msg"];
    
    UITabBarItem *item4 = items[4];
    item4.title = @"我的";
    item4.image = [UIImage imageNamed:@"icon_tab_my_account"];
    
}


- (void)btnAddAction {
    [[SDImageCache sharedImageCache] clearDisk];
    NSLog(@"---清理缓存---");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
